package com.dts.listener;

import jakarta.servlet.ServletRequestAttributeEvent;
import jakarta.servlet.ServletRequestAttributeListener;
import jakarta.servlet.annotation.WebListener;

import java.text.MessageFormat;

@WebListener
public class MyRequestAttributeLitener  implements ServletRequestAttributeListener {
    @Override
    public void attributeAdded(ServletRequestAttributeEvent event){
        System.out.println(MessageFormat.format("ServletContext add Attribute name : {0}，value : {1}",  event.getName(), event.getValue()));
    }
    @Override
    public void attributeRemoved(ServletRequestAttributeEvent event)  {
        System.out.println(MessageFormat.format("ServletContext replace Attribute name : {0}，value : {1}",  event.getName(), event.getValue()));
    }
    @Override
    public void attributeReplaced(ServletRequestAttributeEvent event)  {
        System.out.println(MessageFormat.format("ServletContext remove Attribute name : {0}，value : {1}", event.getName(), event.getValue()));
    }
}
